From 31915d2842e5de14fc82f0f36241e72968315f16 Mon Sep 17 00:00:00 2001 From: Jonathan Dieter Date: Sun, 9 Jan 2022 19:49:28 +0000 Subject: [PATCH] Use meson features to simplify dependency checking Signed-off-by: Jonathan Dieter --- .gitignore | 2 ++ meson.build | 40 +++++++++++++++++----------------------- meson_options.txt | 4 ++-- subprojects/zstd.wrap | 2 +- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 7265574..41352f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ cov-int /build +/subprojects/packagecache +/subprojects/zstd-* test/abi/new test/abi/stable/ABI.dump diff --git a/meson.build b/meson.build index ced4233..453e5fb 100644 --- a/meson.build +++ b/meson.build @@ -18,20 +18,17 @@ if build_machine.system() == 'freebsd' add_project_arguments('-DFREEBSD', language : 'c') endif -if get_option('with-zstd') == 'disabled' - zstd_dep = dependency('', required : false) + +if build_machine.system() == 'windows' + zstd_dep = dependency('zstd', modules: 'zstd::libzstd_shared', required : get_option('with-zstd'), fallback: 'zstd') else - if build_machine.system() == 'windows' - zstd_dep = dependency('zstd', modules: 'zstd::libzstd_shared', required : get_option('with-zstd') == 'enabled') - else - zstd_dep = dependency('libzstd', required : get_option('with-zstd') == 'enabled', - default_options: ['bin_programs=false', 'zlib=disabled', 'lzma=disabled', 'lz4=disabled']) - endif - if zstd_dep.found() - add_project_arguments('-DZCHUNK_ZSTD', language : 'c') - if zstd_dep.version().version_compare('<=1.4.9') - add_project_arguments('-DOLD_ZSTD', language : 'c') - endif + zstd_dep = dependency('libzstd', required : get_option('with-zstd'), fallback: 'zstd', + default_options: ['bin_programs=false', 'zlib=disabled', 'lzma=disabled', 'lz4=disabled']) +endif +if zstd_dep.found() + add_project_arguments('-DZCHUNK_ZSTD', language : 'c') + if zstd_dep.version().version_compare('<=1.4.9') + add_project_arguments('-DOLD_ZSTD', language : 'c') endif endif @@ -41,17 +38,14 @@ else curl_dep = dependency('libcurl') endif -if get_option('with-openssl') == 'disabled' - openssl_dep = dependency('', required : false) + +if build_machine.system() == 'windows' + openssl_dep = dependency('openssl', modules : ['OpenSSL::SSL', 'OpenSSL::Crypto'], required : get_option('with-openssl')) else - if build_machine.system() == 'windows' - openssl_dep = dependency('openssl', modules : ['OpenSSL::SSL', 'OpenSSL::Crypto'], required : get_option('with-openssl') == 'enabled') - else - openssl_dep = dependency('openssl', required : get_option('with-openssl') == 'enabled') - endif - if openssl_dep.found() - add_project_arguments('-DZCHUNK_OPENSSL', language : 'c') - endif + openssl_dep = dependency('openssl', required : get_option('with-openssl')) +endif +if openssl_dep.found() + add_project_arguments('-DZCHUNK_OPENSSL', language : 'c') endif inc = [] diff --git a/meson_options.txt b/meson_options.txt index 7dc221e..bb7dd6c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,3 +1,3 @@ -option('with-zstd', type : 'combo', choices : ['enabled', 'disabled', 'auto'], value : 'auto') -option('with-openssl', type : 'combo', choices : ['enabled', 'disabled', 'auto'], value : 'auto') +option('with-zstd', type : 'feature', value : 'auto') +option('with-openssl', type : 'feature', value : 'auto') option('coverity', type : 'boolean', value : false) diff --git a/subprojects/zstd.wrap b/subprojects/zstd.wrap index 60791f7..68691f8 100644 --- a/subprojects/zstd.wrap +++ b/subprojects/zstd.wrap @@ -8,4 +8,4 @@ patch_filename = zstd-1.4.5-1-wrap.zip patch_hash = fd9cb7b9c8f7092ef1597ff68f170beef65fcf33e575a621955cf405a41db1cc [provide] -zstd = zstd_dep +libzstd = libzstd_dep -- 2.30.2